package com.naizhuai.network.apistore.apistoreiml;

import com.naizhuai.AppContext;
import com.naizhuai.network.Config;
import com.naizhuai.network.RetrofitServerFactory;
import com.naizhuai.network.apistore.CommonManagerApiStore;
import com.naizhuai.network.apistore.CommonManagerRequest;
import com.naizhuai.ui.entity.MainPage;
import com.naizhuai.ui.entity.RecommendScheme;
import com.naizhuai.ui.entity.StartUp;
import com.naizhuai.ui.entity.User.MainPageRedPoint;
import com.naizhuai.ui.entity.User.UserNews;
import com.naizhuai.util.RxUtils;

import java.util.List;

import rx.Observable;

/**
 * @author：lichenxi
 * @date 2018/5/4 12
 * email：525603977@qq.com
 * Fighting
 */
public class CommonManagerIml implements CommonManagerApiStore {

    private static CommonManagerIml INSTANCE = null;

    public static CommonManagerIml getInstance() {
        if (INSTANCE == null) {
            INSTANCE = new CommonManagerIml();
        }
        return INSTANCE;
    }

    @Override
    public Observable<MainPage> getMainPage() {
        return createBaseClass().getMainPage().compose(RxUtils.applySchedulers());
    }

    @Override
    public Observable<StartUp> getStartUp() {
        return createBaseClass().getStartUp().compose(RxUtils.applySchedulers());
    }

    @Override
    public Observable<List<RecommendScheme>> getRecommendScheme(int page) {
        return createBaseClass().getRecommendScheme(page).compose(RxUtils.applySchedulers());
    }
    //1登录2登出
    @Override
    public Observable<String> user_report(String jid,String type) {
        return createBaseClass().user_report(jid,type).compose(RxUtils.applySchedulers());
    }

    @Override
    public Observable<List<UserNews>> article_list() {
        return createBaseClass().article_list().compose(RxUtils.applySchedulers());
    }

    @Override
    public Observable<MainPageRedPoint> red_point() {
        return createBaseClass().red_point().compose(RxUtils.applySchedulers());
    }

    private CommonManagerRequest createBaseClass() {
        return RetrofitServerFactory.create(AppContext.getInstance(), CommonManagerRequest.class, Config.TEST_ACTION_BASE_URL);
    }


}
